
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results liang_g2', {
	set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results liang_g2')
    result <- sampler(100000, vy, mX, prior='liang_g2', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, c(
		0.9544200000000000,0.8700100000000000,0.3064800000000000,0.8621200000000000,
		0.2789700000000000,0.6560600000000000,0.2510500000000000,0.4098600000000000,
		0.2769200000000000,0.5556300000000000,0.4853300000000000,0.4531300000000000,
		0.2581100000000000,0.2950200000000000,0.1721500000000000,0.1862400000000000,
		0.2547200000000000,0.2384200000000000,0.3761000000000000,0.2205700000000000,
		0.3786900000000000,0.3114700000000000,0.3950200000000000,0.2736600000000000,
		0.2561700000000000,0.2076500000000000,0.2844200000000000,0.2215000000000000,
		0.5234100000000000,0.2842700000000000,0.6075600000000000,0.2140700000000000,
		0.2110600000000000,0.2602500000000000,0.3965100000000000,0.2248100000000000,
		0.2425500000000000,0.2391600000000000,0.2235600000000000,0.8088000000000000,
		0.3391400000000000,0.2436800000000000,0.3997600000000000,0.6137500000000000,
		0.3200200000000000,0.5093200000000000,0.1987800000000000,0.2034700000000000,
		0.8568300000000000,0.9657300000000000,0.9638600000000001,0.1940300000000000,
		0.2670000000000000,0.3017900000000000,0.6335300000000000,0.2234100000000000,
		0.3057200000000000,0.2673900000000000,0.2448100000000000,0.3417800000000000,
		0.2296900000000000,0.4130500000000000,0.3107200000000000,0.3819300000000000,
		0.4578400000000000,0.3973000000000000,0.4305400000000000,0.7434400000000000,
		0.2540300000000000,0.1746400000000000,0.9404000000000000,0.2939500000000000,
		0.4155700000000000,0.2014400000000000,0.2795300000000000,0.1957200000000000,
		0.2625600000000000,0.4036600000000000,0.4234100000000000,0.3201700000000000,
		0.3497100000000000,0.2157700000000000,0.2425300000000000,0.5873000000000000,
		0.3849400000000000,0.1792100000000000,0.7591000000000000,0.2247600000000000,
		0.3996000000000000,0.6204000000000000,0.1952700000000000,0.2182600000000000,
		0.8663300000000000,0.2514200000000000,0.2246700000000000,0.1866900000000000,
		0.1768500000000000,0.1768700000000000,0.9513600000000000
	)
, tolerance = 1e-5)
})